package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlWsbase;
import com.ruoyi.sl.service.ISlWsbaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车间绩效系数Controller
 * 
 * @author admin
 * @date 2024-06-03
 */
@RestController
@RequestMapping("/sl/wsbase")
public class SlWsbaseController extends BaseController
{
    @Autowired
    private ISlWsbaseService slWsbaseService;

    /**
     * 查询车间绩效系数列表
     */
    @PreAuthorize("@ss.hasPermi('sl:wsbase:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlWsbase slWsbase)
    {
        startPage();
        List<SlWsbase> list = slWsbaseService.selectSlWsbaseList(slWsbase);
        return getDataTable(list);
    }

    /**
     * 导出车间绩效系数列表
     */
    @PreAuthorize("@ss.hasPermi('sl:wsbase:export')")
    @Log(title = "车间绩效系数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlWsbase slWsbase)
    {
        List<SlWsbase> list = slWsbaseService.selectSlWsbaseList(slWsbase);
        ExcelUtil<SlWsbase> util = new ExcelUtil<SlWsbase>(SlWsbase.class);
        util.exportExcel(response, list, "车间绩效系数数据");
    }

    /**
     * 获取车间绩效系数详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:wsbase:query')")
    @GetMapping(value = "/{wsbaseId}")
    public AjaxResult getInfo(@PathVariable("wsbaseId") Long wsbaseId)
    {
        return success(slWsbaseService.selectSlWsbaseByWsbaseId(wsbaseId));
    }

    /**
     * 新增车间绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:wsbase:add')")
    @Log(title = "车间绩效系数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlWsbase slWsbase)
    {
        slWsbase.setCreateBy(getUsername());
        return toAjax(slWsbaseService.insertSlWsbase(slWsbase));
    }

    /**
     * 修改车间绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:wsbase:edit')")
    @Log(title = "车间绩效系数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlWsbase slWsbase)
    {
        slWsbase.setUpdateBy(getUsername());
        return toAjax(slWsbaseService.updateSlWsbase(slWsbase));
    }

    /**
     * 删除车间绩效系数
     */
    @PreAuthorize("@ss.hasPermi('sl:wsbase:remove')")
    @Log(title = "车间绩效系数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wsbaseIds}")
    public AjaxResult remove(@PathVariable Long[] wsbaseIds)
    {
        return toAjax(slWsbaseService.deleteSlWsbaseByWsbaseIds(wsbaseIds));
    }
}
